#include <stdio.h>
#include <stdlib.h>
#include <csp_spu.h>
#include <csp_debug.h>

int global_pid; 

unsigned char _75KB[75][1024];

void touch_data(unsigned char mark){
	_75KB[mark][mark] = mark;
}


void test(unsigned char mark){
	int x;
	for(x=0; x < mark; x++){
			ASSERT( ((unsigned char) x) ==  _75KB[x][x] );
	}	
	printf("_75KB[%i][%i]=%u\n", mark-1, mark-1, 
			(uint32_t) _75KB[mark-1][mark-1] );
}

int Run(){
	unsigned char test_value, i;
	int pid = csp_pid();

	global_pid = csp_pid();

	test_value = (unsigned char) (pid % 100) + 10 ;
	
	for(i=0; i <= test_value; i++){
		touch_data(i);
		csp_yield();
	}

	test(test_value);

	ASSERT( pid == csp_pid() );
	ASSERT( global_pid == csp_pid() );

	PRINTF_FOR_TESTING("%s terminating on spe #%i with pid %i\n",__FILE__ , csp_spe_id(), pid);

	PRINTF_FOR_TESTING("Nested task with pid=%i terminated with res=%i.\n", pid, res);

	return 0;
}
